class Solution():
    def longestConsecutive(self,nums):
        set_nums = set(nums)
        longest = 0
        for num in set_nums:
            if num-1 in set_nums:
                continue
            else:
                check_num = num + 1
                current = 1
                while check_num in set_nums:
                    current = current +1
                    check_num = check_num + 1
                if current > longest :
                    longest = current
        return longest
